<template>
  <div v-if="show" class="modal-dialog" @click="clickModal">
    <slot></slot>
  </div>
</template>

<script lang="ts" setup>
  const emits = defineEmits(['close'])
  const props = defineProps({
    show: {
      type: Boolean,
      default: false
    }
  })

  const clickModal = (e: any) => {
    if (e.target.className == 'modal-dialog') {
      console.log('调用关闭')
      emits('close')
    }
  }
</script>

<style lang="scss">
  .modal-dialog {
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: rgba($color: #000000, $alpha: 0.3);
    overflow: hidden;
    top: 0;
    left: 0;
    z-index: 2001;
    display: flex;
    justify-content: center;
    align-items: center;
  }
</style>
